﻿<cfsilent>
	<cfscript>
		
		subjectId = event.getArg("SBJ");
		grade = event.getArg("GRD");
		studentId = event.getArg("STU");
		
		/* 读取学生已替换的成绩 */
		sql = "SELECT 
						b.cid, b.course_name, b.course_credit, 
						a.scm_id, 
						a.retaking, a.mark_mode, 
						a.mark_result, a.mark_note, 
						a.mark_resit, a.mark_renote, a.mark_resit_limit, 
						c.prop_name, 
						d.rep_desc, d.rep_mark, 
						e.tch_name 
					FROM t_student_mark a 
						 INNER JOIN t_course b ON b.cid = a.cid 
						 INNER JOIN t_course_prop c ON c.prop_id = a.prop_id 
						 INNER JOIN t_mark_replace d ON d.scm_id = a.scm_id 
						 INNER JOIN t_teacher e ON e.tch_id = d.tch_id 
					WHERE 
						  a.stu_id = :studentId 
					ORDER BY b.course_name ";
		
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="studentId", value=studentId, cfsqltype="cf_sql_varchar" );
			
		rs_replace_mark = queryObj.execute( sql=sql ).getResult();
		
		
		/* 读取学生已替换的课程 */
		sql = "SELECT 
					a.course_code, a.course_name, a.course_credit, 
					b.course_code course_code_replace, b.course_name course_name_replace, b.course_credit course_credit_replace, 
					s.stu_crp, 
					c.tch_name 
				FROM t_student_course_replace s 
					INNER JOIN t_course a ON a.cid = s.cid_a 
					INNER JOIN t_course b ON b.cid = s.cid_b 
					INNER JOIN t_teacher c ON c.tch_id = s.tch_id 
				WHERE 
					s.stu_id = :studentId ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="studentId", value=studentId, cfsqltype="cf_sql_varchar" );
			
		rs_replace_course = queryObj.execute( sql=sql ).getResult();
		
		
		passArgs = structNew();
		structInsert( passArgs, "SBJ", subjectId, true );
		structInsert( passArgs, "GRD", grade, true );
		structInsert( passArgs, "STU", studentId, true );
		
	</cfscript>
</cfsilent>

					<div class="noticeBlock">
						<h2 class="UILeadHead markReplace"><span>成绩替代关系</span></h2>
					</div>
					
					<cfif rs_replace_mark.recordCount>
					
						<table class="UItable markReplace">
							<tr class="cellDivide cellHeader">
								<td>课程</td>
								<td width="60">原始成绩</td>
								<td width="60">替换成绩</td>
								<td width="400">操作日志</td>
								<td width="50">审核人</td>
								<td width="18"></td>
							</tr>
							<tbody>
								<cfloop query="rs_replace_mark">
								
									<cfset structInsert( passArgs, "SCMID", rs_replace_mark.scm_id, true ) />
									<cfset markFinal = markAdvice.getMarkResult( rs_replace_mark.mark_mode, rs_replace_mark.mark_result, rs_replace_mark.mark_note, rs_replace_mark.mark_resit, rs_replace_mark.mark_renote, rs_replace_mark.mark_resit_limit ) />
									<cfset markReplaced = rs_replace_mark.rep_mark />
								
									<tr class="cellDivide">
										<td><cfoutput>#rs_replace_mark.course_name#</cfoutput></td>
										<td align="center">
											<cfif isNumeric(markFinal)>
													<span class="number"><cfoutput>#replace( markFinal, ".0", "" )#</cfoutput></span>
												<cfelse>
													<cfoutput>#markFinal#</cfoutput>
											</cfif>
										</td>
										<td align="center">
											<cfif isNumeric(markReplaced)>
													<span class="number"><cfoutput>#replace( markReplaced, ".0", "" )#</cfoutput></span>
												<cfelse>
													<cfoutput>#markReplaced#</cfoutput>
											</cfif>
										</td>
										<td><cfoutput>#rs_replace_mark.rep_desc#</cfoutput></td>
										<td><cfoutput>#rs_replace_mark.tch_name#</cfoutput></td>
										<td><a title="删除成绩替代" href="<cfoutput>#buildURL('removeMarkReplaceDo', passArgs)#</cfoutput>" class="operation recoverCourse"></a></td>
									</tr>
								</cfloop>
								<!--- 移除额外参数 --->
								<cfset structDelete( passArgs, "SCMID", false ) />
							</tbody>
						</table>
						
						<cfelse>
						
						<div class="systemNotice">
							<p>目前还没有指定成绩替代关系</p>
						</div>
						
					</cfif>
					
					
					<div class="noticeBlock">
						<h2 class="UILeadHead courseReplace"><span>课程替代关系</span></h2>
					</div>
					
					<cfif rs_replace_course.recordCount>
						
						<table class="UItable courseReplace">
							<tr class="cellDivide cellHeader">
								<td width="160">课程号</td>
								<td>原课程</td>
								<td align="center" width="40">学分</td>
								<td>替换课程</td>
								<td align="center" width="60">替换学分</td>
								<td width="50">审核人</td>
								<td width="18"></td>
							</tr>
							<tbody>
								<cfloop query="rs_replace_course">
									
									<cfset structInsert( passArgs, "REPID", rs_replace_course.stu_crp, true ) />
									
									<tr class="cellDivide">
										<td><span class="number"><cfoutput>#rs_replace_course.course_code#</cfoutput> --&gt; <cfoutput>#rs_replace_course.course_code_replace#</cfoutput></span></td>
										<td><cfoutput>#rs_replace_course.course_name#</cfoutput></td>
										<td align="center"><span class="number"><cfoutput>#rs_replace_course.course_credit#</cfoutput></span></td>
										<td><cfoutput>#rs_replace_course.course_name_replace#</cfoutput></td>
										<td align="center"><span class="number"><cfoutput>#rs_replace_course.course_credit_replace#</cfoutput></span></td>
										<td><cfoutput>#rs_replace_mark.tch_name#</cfoutput></td>
										<td><a title="删除课程成绩替代" href="<cfoutput>#buildURL('removeCourseReplaceDo', passArgs)#</cfoutput>" class="operation recoverCourse"></a></td>
									</tr>
								</cfloop>
								<!--- 移除额外参数 --->
								<cfset structDelete( passArgs, "REPID", false ) />
							</tbody>
						</table>
						
						<cfelse>
						
						<div class="systemNotice">
							<p>目前还没有指定课程替代关系</p>
						</div>
						
					</cfif>
					
					

